﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Meqs.Entity;
using Meqs.Logic.Interface;
using System.Collections.Generic;
using System.Web.Services;

public partial class Credit_Teacher_RuleSettings_Formula : ContainerBasePage
{
    protected IList<StuCauseCipher> keyparam = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark",SchoolCommon.Sch_SchoolInfo.SchoolMark);
            keyparam = Container<IStuCauseCipherLogic>.Instance.FindAll(ht);
        }
    }
    protected void btnBind_Click(object sender, EventArgs e)
    {
    }
    protected void InitKeyParam()
    {
        if (keyparam != null)
        {
            Response.Write(" var tempObj;");
            for (int i = 0; i < 5; i++)
            { 
                if(keyparam[i].KeyWord == "DayLimit")
                    continue;

                Response.Write("  tempObj = document.getElementById('text"+(i+1)+"');");
                Response.Write("  tempObj.value =" + keyparam[i].Paramer + ";");
                Response.Write("  tempObj.oldvalue =" + keyparam[i].Paramer + ";");
                Response.Write("  tempObj.KeyWord ='" + keyparam[i].KeyWord + "';");
            }
        }
    }
    [WebMethod]//KindSettingsEducation[] kinds, int examid, int subjectid
    public static StuCauseCipher[] GetParams(int courseID)
    {
        IList<StuCauseCipher> keyparam = Container<IStuCauseCipherLogic>.Instance.FindCipherByCourse(courseID, SchoolMark);
        StuCauseCipher[] scc = new StuCauseCipher[keyparam.Count];
        for (int i = 0; i < keyparam.Count; i++)
        {
            scc[i] = keyparam[i];
        }
        return scc;
    }
    [WebMethod]//KindSettingsEducation[] kinds, int examid, int subjectid
    public static void SaveParamSet(int courseID, int[] param,string [] kwords)
    {
        IList<StuCauseCipher> keyparam = Container<IStuCauseCipherLogic>.Instance.FindCipherByCourse(courseID, SchoolMark);
        foreach(StuCauseCipher scc in keyparam)
        {
            for (int i = 0; i < param.Length; i++)
            {
                if (kwords[i] != scc.KeyWord)
                    continue;
                scc.Paramer = param[i];
                scc.SchoolMark = SchoolMark;
                Container<IStuCauseCipherLogic>.Instance.Update(scc);
            }
        }
    }

    [WebMethod]
    public static IList<GlobalCauseInfo> GetCourse()
    {
        IGlobalCauseInfoLogic causeLogic = Container<IGlobalCauseInfoLogic>.Instance;
        IList<GlobalCauseInfo> causeList = causeLogic.SelectSchoolCause(SchoolMark,1);
        return causeList;
    }

    [WebMethod]
    public static IList<StuCauseCipher> GetCipher(int courseID)
    {
        IStuCauseCipherLogic sccLogic = Container<IStuCauseCipherLogic>.Instance;
        IList<StuCauseCipher> causeList = sccLogic.FindCipherByCourse(courseID, SchoolMark);
        return causeList;
    }
}
